package com.smz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smz.entity.TIoWarehouse;
import com.smz.service.TIoWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class TIoWarehouseController {

    @Autowired
    private TIoWarehouseService tIoWarehouseService;


    /**
     * @Authoe: smz
     * @Description: 出入库分页查询
     * @Date: 8:57 2021-11-25
     */
    @GetMapping("/tIoWareHouses/{current}/{size}")
    public ResponseEntity<IPage<TIoWarehouse>> findAll(@PathVariable("current") int current, @PathVariable("size") int size){
        IPage<TIoWarehouse> pageTIoWareHouse = tIoWarehouseService.findPageTIoWareHouse(current, size);
        return ResponseEntity.ok(pageTIoWareHouse);
    }

    /**
      * @Authoe: smz
      * @Description: 出库新增数据
     * @Date: 15:36 2021-12-01
      */
    @PostMapping("/tIoWareHouses")
    public ResponseEntity<String> addTIoWareHouses(@RequestBody TIoWarehouse outTIoWareHouse){
        System.out.println(outTIoWareHouse);
        tIoWarehouseService.addTIoWareHouses(outTIoWareHouse);
        return ResponseEntity.ok("ok");
    }

    /**
      * @Authoe: smz
      * @Description:   搜索框搜索+分页
      * @Date: 20:05 2021-12-01
      */
    @GetMapping("/tIoWareHouses/{orderNumber}/{lot}/{size}/{current}")
    public ResponseEntity<IPage<TIoWarehouse>> findTIoWareHouses(@PathVariable("orderNumber") String orderNumber, @PathVariable("lot") String lot,
                                                                 @PathVariable("size") int size, @PathVariable("current") int current){
        IPage<TIoWarehouse> pageByNumberAndName = tIoWarehouseService.findPageByNumberAndName(orderNumber, lot, size, current);
        return ResponseEntity.ok(pageByNumberAndName);
    }
}
